<?php
namespace app\demo\enum;

final class Grade{

    const ONE=1;

    const TWO=2;

    const THREE=3;

    const FOUR=4;

    public static function options(){
        $options=[
            self::ONE=>"一年级",
            self::TWO=>"二年级",
            self::THREE=>"三年级",
            self::FOUR=>"四年级",
        ];
        return $options;
    }

    public static function code($text='',$default=''){
        $options=self::options();
        $code=array_search($text,$options);
        return $code==false?$default:$code;
    }

    public static function codes(){
        return array_keys(self::options());
    }

    public static function text($code='',$default=''){
        $options=self::options();
        return isset($options[$code])?$options[$code]:$default;
    }

    public static function texts(){
        return array_values(self::options());
    }

}